package Singleton;

public class SingleObject {

    // 2、
    private static SingleObject onlyOneObj;

    // 私有化 构造函数, 这样该类就不会被实例化.
    private SingleObject(){}

    public static synchronized SingleObject getInstance(){
        if ( onlyOneObj == null ){
            onlyOneObj = new SingleObject();
        }
        return onlyOneObj;
    }

}
